package xian.woniuxy.be.entity;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @author ljy
 * @time 2022/01/03 14:44:47
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class ResultVO {
    private int code;
    private String msg;
    private Object data;

    public ResultVO(int code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public static ResultVO success(){
        return success("操作成功", null);
    }

    public static ResultVO success(String msg){
        return success(msg, null);
    }

    public static ResultVO success(Object data){
        return success("操作成功",data);
    }

    public static ResultVO success(String msg,Object data){
        return new ResultVO(200,msg,data);
    }

    public static ResultVO failure(){
        return failure("操作失败", null);
    }

    public static ResultVO failure(String msg){
        return failure(msg, null);
    }

    public static ResultVO failure(Object data){
        return failure("操作失败",data);
    }

    public static ResultVO failure(String msg,Object data){
        return new ResultVO(500,msg,data);
    }
}
